package com.yangwudi.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.yangwudi.mapper.OperateLogMapper;
import com.yangwudi.pojo.OperateLogQueryParam;
import com.yangwudi.pojo.OperateLog;
import com.yangwudi.pojo.PageResult;
import com.yangwudi.service.OperateLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OperateLogServiceImpl implements OperateLogService {
    @Autowired
    private OperateLogMapper operateLogMapper;
    @Override
    public PageResult page(OperateLogQueryParam operateLogQueryParam) {
        //1. 设置分页参数
        PageHelper.startPage(operateLogQueryParam.getPage(), operateLogQueryParam.getPageSize());

        //2. 执行查询
        List<OperateLog> operateLogList = operateLogMapper.list(operateLogQueryParam);

        //3. 解析查询结果，并封装
        Page<OperateLog> p = (Page<OperateLog>) operateLogList;
        return new PageResult<OperateLog>(p.getTotal(),p.getResult());
    }
}
